/*      > H.Bag - Bag data type header file */

#ifndef __bag_h

#define __bag_h

struct bag
{
        void *first;    /* pointer to first element of bag */
        int obj_size;   /* size of one element */
};

typedef struct bag *bag;

/* General component routines */

bag bag_new (int obj_len);
void bag_free (bag b);
void bag_clear (bag b);
int bag_copy (bag b1, const bag b2);
int bag_equal (const bag b1, const bag b2);
int bag_empty (const bag b);
int bag_size (const bag b);

/* Iterator */

#define STATUS_CONTINUE 0       /* Continue processing */
#define STATUS_STOP     1       /* Stop processing */
#define STATUS_ERROR    (-1)    /* Error - terminate */

int bag_iterate (const bag b, int (*process)(void *, int));

/* Bag-specific routines */

int bag_add (bag b, const void *object);
int bag_remove (bag b, const void *object);
int bag_member (const bag b, const void *object);
int bag_count (const bag b, const void *object);
int bag_union (bag b1, const bag b2, const bag b3);
int bag_intersection (bag b1, const bag b2, const bag b3);
int bag_difference (bag b1, const bag b2, const bag b3);
int bag_unique_count (const bag b);
int bag_subset (const bag b1, const bag b2);
int bag_proper_subset (const bag b1, const bag b2);

#endif
